import { Controller, Post, Body, Param } from '@nestjs/common';
import { RoleMenuService } from './role-menu.service';
import { CreateRoleMenuDto } from './dto/create-role-menu.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Result } from 'src/utils/Result';

@ApiTags('角色菜单')
@Controller('role-menu')
export class RoleMenuController {
  constructor(private readonly roleMenuService: RoleMenuService) {}

  @Post()
  create(@Body() createRoleMenuDto: CreateRoleMenuDto) {
    return this.roleMenuService.create(createRoleMenuDto);
  }
  @ApiOperation({ description: '获取角色下的菜单id列表' })
  @Post('role-in-menu:id')
  async findAll(@Param('id') role_id: number) {
    const result = await this.roleMenuService.findRoleInMenUIds(role_id);
    return Result.success(result)
  }
  @Post('del:id')
  remove(@Param('id') id: string) {
    return this.roleMenuService.remove(+id);
  }
}
